//
//  SearchTagCell.m
//  jipin
//
//  Created by lcb on 5/28/15.
//  Copyright (c) 2015 liuchengbin. All rights reserved.
//

#import "SearchTagCell.h"

#import "AOTag.h"

@interface SearchTagCell ()<AOTagDelegate>
{
    
}

@property (nonatomic, strong) AOTagList *tagList;
@property(nonatomic,strong)UILabel *titleLabel;
@property(nonatomic,strong) UIView *bgView;
@end
@implementation SearchTagCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        self.backgroundColor=[UIColor clearColor];
        _bgView =[[UIView alloc] initWithFrame:CGRectMake(0, 0, DEVICE_WIDTH, 0)];
        _bgView.backgroundColor=[UIColor clearColor];
        [self.contentView addSubview:_bgView];
        
//        _titleLabel =[[UILabel alloc] initWithFrame:CGRectMake(PHOTO_FRAME_WIDTH, PHOTO_TIME_PADDING, 30, 23)];
//        _titleLabel.backgroundColor = [UIColor clearColor];
//        _titleLabel.textColor = UIColorFromRGB(0x999999);
//        _titleLabel.textAlignment = NSTextAlignmentLeft;
//        _titleLabel.font = FONT_14;
//        _titleLabel.text =@"标签:";
//        _titleLabel.numberOfLines=0;
////        [_bgView addSubview:_titleLabel];
        
        _tagList = [[AOTagList alloc] initWithFrame:CGRectMake(PHOTO_FRAME_WIDTH, 0, DEVICE_WIDTH-PHOTO_FRAME_WIDTH*2, 80)];
        _tagList.backgroundColor =[UIColor clearColor];
        _tagList.delegate=self;
        [_bgView addSubview:_tagList];
        
    }
    return self;
}
-(void)dealloc
{
    self.tagList.delegate=nil;
    self.tagList=nil;
    self.bgView=nil;
    self.titleLabel=nil;
    self.data=nil;
    //    DLog(@"%s", __PRETTY_FUNCTION__);
}

- (void)layoutSubviews
{
    [super layoutSubviews];
}
/// 根据数据模型来显示内容
- (void)showInfo:(id)model key:(id)key indexPath:(NSIndexPath *)indexPath
{
    self.key =key;
    self.data =model;
    [self showInfo:model indexPath:indexPath];
}
/// 根据数据模型来显示内容
- (void)showInfo:(id)model indexPath:(NSIndexPath *)indexPath
{
    NSArray *tagAr =(NSArray *)model;
    self.data =tagAr;
    self.indexPath =indexPath;
    float fTop = [self.tagList addTags:tagAr limitLine:10 type:@"SearchTagCell"];
    _tagList.frame =CGRectMake(PHOTO_FRAME_WIDTH, 0, DEVICE_WIDTH-PHOTO_FRAME_WIDTH*2, fTop);
    _bgView.frame=CGRectMake(0, 0,self.bounds.size.width, fTop);
    [self layoutSubviews];
}
/// 返回Cell高度
+ (CGFloat)returnCellHeight:(id)model
{
    NSArray *tagAr =(NSArray *)model;
    SearchTagCell *tc =[[SearchTagCell alloc] init];
   
    float fTop = [tc.tagList addTags:tagAr limitLine:10 type:@"SearchTagCell"];
    tc = nil;
    return fTop+PHOTO_FRAME_WIDTH;
}
- (void)tagDidSelectTag:(AOTag *)tag
{
    if (self.actionBlock) {
        self.actionBlock(BEventType_tag,self,tag.tTitle,self.key,self.indexPath);
    }
}
-(void)setCallBack:(void(^)(BEventType,UIView*,id,id,NSIndexPath *))callback
{
    self.actionBlock=callback;
}

@end
